package ModelLayer;

import java.util.ArrayList;

/**
 * Write a description of class DVD here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class DVD
{
    private int barcode;
    private String title;
    private String artist;
    private String publicationDate;
    private ArrayList<Copy> copies;

    /**
     * Constructor for objects of class DVD
     */
    public DVD(int barcode, String title, String artist, String publicationDate)
    {
        this.barcode = barcode;
        this.title = title;
        this.artist = artist;
        this.publicationDate = publicationDate;
        copies = new ArrayList<Copy>();
    }

    public void setBarcode(int barcode)
    {
        this.barcode = barcode;
    }

    public int getBarcode()
    {
        return barcode;
    }

    public void setTitle(String title)
    {
        this.title = title;
    }

    public String getTitle()
    {
        return title;
    }

    public void setArtist(String artist)
    {
        this.artist = artist;
    }

    public String getArtist()
    {
        return artist;
    }

    public void setPublicationDate(String publicationDate)
    {
        this.publicationDate = publicationDate;
    }

    public String getPublicationDate()
    {
        return publicationDate;
    }

    public void addCopy(Copy copy)
    {
        copies.add(copy);
    }

    public void addNewCopy(String serialNumber, String purchaseDate, String purchasePrice)
    {
        Copy copy = new Copy(serialNumber,purchaseDate,purchasePrice);
        copies.add(copy);
    }

    //     public boolean addNewCopy(String serialNumber, String purchaseDate, String purchasePrice)
    //     {
    //         boolean consist = false;
    //         boolean added = false;
    //         Copy copy = new Copy(serialNumber,purchaseDate,purchasePrice);
    //         for(int i=0; i<copies.size(); i++)
    //         {
    //             if(copies.get(i).getSerialNumber() == serialNumber)
    //             {
    //                 consist = true;
    //             }
    //         }
    //         
    //         if(consist == false) 
    //         {
    //             copies.add(copy);
    //             added = true;
    //         }
    //         return added;
    //     }

    public Copy getCopy()
    {
        if(copies.size()>0) 
        {
            int i=0;
            while(copies.get(i) == null)
            {
                i++;
            }
            return copies.get(i);
        } 
        else 
        {
            return null;
        }        
    }

    public ArrayList<Copy> getCopyList()
    {
        return copies;
    }
}
